* program to estimate exchange rate regression 10/13/07, w/LYS dummy interactions, drop if lrer < 10
set more off


capture log close
log using c:\user\wei\ca\xrreg1.log, replace
cd "c:\\user\wei\ca"
clear
use "CA_wERR.dta"
set more off

drop lys_er defacto_reinrog_er
merge cn year using EXRregimeIndex
drop _merge
sort cn year
merge cn year using real_eff_ifs

gen lrer = log(real_eff_ifs)
drop if current < -1
drop if lrer > 10
drop if lys_er == 1

sort country year
gen lagcurrent = current[_n-1] if year > 1970
gen laglrer = lrer[_n-1] if year > 1970
gen lys = lys_er-2

drop if lrer >10
gen open=opn/100
gen lys0 = 0 if lys!=.
gen lys1 = 0 if lys!=.
gen lys2 = 0 if lys!=.
gen lys3 = 0 if lys!=.
replace lys0 = 1 if lys==0
replace lys1 = 1 if lys==1
replace lys2 = 1 if lys==2
replace lys3 = 1 if lys==3





**** interaction terms

gen laglreropen = laglrer*open
gen laglrerka = laglrer*kaopen
gen laglrer0 = laglrer*lys0
gen laglrer1 = laglrer*lys1
gen laglrer2 = laglrer*lys2
gen laglrer3 = laglrer*lys3

gen yr71=1 if year==1971
replace yr71=0 if yr71==.
gen yr72=1 if year==1972
replace yr72=0 if yr72==.
gen yr73=1 if year==1973
replace yr73=0 if yr73==.
gen yr74=1 if year==1974
replace yr74=0 if yr74==.
gen yr75=1 if year==1975
replace yr75=0 if yr75==.
gen yr76=1 if year==1976
replace yr76=0 if yr76==.
gen yr77=1 if year==1977
replace yr77=0 if yr77==.
gen yr78=1 if year==1978
replace yr78=0 if yr78==.
gen yr79=1 if year==1979
replace yr79=0 if yr79==.

gen yr80=1 if year==1980
replace yr80=0 if yr80==.
gen yr81=1 if year==1981
replace yr81=0 if yr81==.
gen yr82=1 if year==1982
replace yr82=0 if yr82==.
gen yr83=1 if year==1983
replace yr83=0 if yr83==.
gen yr84=1 if year==1984
replace yr84=0 if yr84==.
gen yr85=1 if year==1985
replace yr85=0 if yr85==.
gen yr86=1 if year==1986
replace yr86=0 if yr86==.
gen yr87=1 if year==1987
replace yr87=0 if yr87==.
gen yr88=1 if year==1988
replace yr88=0 if yr88==.
gen yr89=1 if year==1989
replace yr89=0 if yr89==.

gen yr90=1 if year==1990
replace yr90=0 if yr90==.
gen yr91=1 if year==1991
replace yr91=0 if yr91==.
gen yr92=1 if year==1992
replace yr92=0 if yr92==.
gen yr93=1 if year==1993
replace yr93=0 if yr93==.
gen yr94=1 if year==1994
replace yr94=0 if yr94==.
gen yr95=1 if year==1995
replace yr95=0 if yr95==.
gen yr96=1 if year==1996
replace yr96=0 if yr96==.
gen yr97=1 if year==1997
replace yr97=0 if yr97==.
gen yr98=1 if year==1998
replace yr98=0 if yr98==.
gen yr99=1 if year==1999
replace yr99=0 if yr99==.


gen yr00=1 if year==2000
replace yr00=0 if yr00==.
gen yr01=1 if year==2001
replace yr01=0 if yr01==.
gen yr02=1 if year==2002
replace yr02=0 if yr02==.
gen yr03=1 if year==2003
replace yr03=0 if yr03==.
gen yr04=1 if year==2004
replace yr04=0 if yr04==.
gen yr05=1 if year==2005
replace yr05=0 if yr05==.

iis(cn)

local filename WEI_results_xr2.out
local switches se 3aster nolabel r2






**** full sample
xtreg lrer laglrer yr72-yr05 , fe robust cluster(cn)
	outreg using "`filename'", replace `switches'
xtreg lrer laglrer laglrer1 laglrer2 laglrer3 lys1 lys2 lys3 yr72-yr05, fe robust cluster(cn)
	outreg using "`filename'", append `switches'
xtreg lrer laglrer laglrer1 laglrer2 laglrer3 lys1 lys2 lys3 laglreropen laglrerka open kaopen yr72-yr05, fe robust cluster(cn)
	outreg using "`filename'", append `switches'


**** idc
xtreg lrer laglrer yr72-yr05 if idc==1, fe robust cluster(cn)
	outreg using "`filename'", append `switches'

xtreg lrer laglrer laglrer1 laglrer2 laglrer3 lys1 lys2 lys3 yr72-yr05 if idc==1, fe robust cluster(cn)
	outreg using "`filename'", append `switches'
xtreg lrer laglrer laglrer1 laglrer2 laglrer3 lys1 lys2 lys3 laglreropen laglrerka open kaopen yr72-yr05 if idc==1, fe robust cluster(cn)
	outreg using "`filename'", append `switches'

**** non-idc
xtreg lrer laglrer yr72-yr05 if idc!=1, fe robust cluster(cn)
	outreg using "`filename'", append `switches'

xtreg lrer laglrer laglrer1 laglrer2 laglrer3 lys1 lys2 lys3 yr72-yr05 if idc!=1, fe robust cluster(cn)
	outreg using "`filename'", append `switches'
xtreg lrer laglrer laglrer1 laglrer2 laglrer3 lys1 lys2 lys3 laglreropen laglrerka open kaopen yr72-yr05 if idc!=1, fe robust cluster(cn)
	outreg using "`filename'", append `switches'

**** non-idc, non-oil
xtreg lrer laglrer yr72-yr05 if idc!=1 & oil!=1, fe robust cluster(cn)
	outreg using "`filename'", append `switches'

xtreg lrer laglrer laglrer1 laglrer2 laglrer3 lys1 lys2 lys3 yr72-yr05 if idc!=1 & oil!=1, fe robust cluster(cn)
	outreg using "`filename'", append `switches'
xtreg lrer laglrer laglrer1 laglrer2 laglrer3 lys1 lys2 lys3 laglreropen laglrerka open kaopen yr72-yr05 if idc!=1 & oil!=1, fe robust cluster(cn)
	outreg using "`filename'", append `switches'



log close



